An operating system (OS) can be run as application on a computer using a virtual machine. The OS that is run as the application is referred to as the “guest OS,” and the underlying OS is referred to as the “host OS.” For example, a Windows-based OS can be run as an application on top of a host Linux OS. Running the Windows-based OS as an application allows programs written for a Windows environment to be run on top of the host Linux OS.
The guest OS usually has a different “context” than the host OS. A context embodies the accessible state of the computer's central processing unit (CPU). The context includes in particular the values of CPU registers. It does not include resources that the CPU would not allow currently executing code to access.
The values of certain registers may need to be different to execute the guest OS than to execute the host OS. The virtual machine can allow the guest OS and the host OS to run concurrently by properly restoring the context of the guest OS whenever control is transferred from the host OS to the guest OS, and by similarly restoring the context of the host OS when control is transferred from the guest OS to the host OS. This process is called “context switching”, and is similar in principle to switching the context between applications in time-shared environments. Most CPU architectures offer built-in support for switching context between applications, making it possible to completely save and restore the context of any application. This support often includes saving selected CPU resources when an interruption occurs, and reserving certain registers for use only by the OS.
Certain CPU architectures, such as IA-64, have prohibitions against, and difficulties with, completely saving and restoring the entire context of the guest OS or host OS. Specifically, certain registers might be corrupted by the context switching process. If the entire context cannot be saved, the guest OS or host OS might behave incorrectly and crash.